const state = {
  fileName: '',
  menuVisible: false,
  settingVisible: -1, // -1不显示  0 字号  1 主题  2 进度 3目录
  defaultFontSize: 16,
  defaultFontFamily: 'Default',
  currentBook: null,
  settingFontPopup: false,
  defaultTheme: 'Default',
  progress: 0,
  bookAvailable: false
}
const mutations = {
  'SET_FILENAME': (state, fileName) => {
    state.fileName = fileName
  },
  'SET_MENUVISIBLE': (state, menuVisible) => {
    state.menuVisible = menuVisible
  },
  'SET_SETTINGVISIBLE': (state, settingVisible) => {
    state.settingVisible = settingVisible
  },
  'SET_DEFAULT_FONT_SIZE': (state, defaultFontSize) => {
    state.defaultFontSize = defaultFontSize
  },
  'SET_CURRENT_BOOK': (state, currentBook) => {
    state.currentBook = currentBook
  },
  'SET_SETTING_FONT_POPUP': (state, settingFontPopup) => {
    state.settingFontPopup = settingFontPopup
  },
  'SET_DEFAULT_FONT_FAMILY': (state, defaultFontFamily) => {
    state.defaultFontFamily = defaultFontFamily
  },
  'SET_DEFAULT_THEME': (state, defaultTheme) => {
    state.defaultTheme = defaultTheme
  },
  'SET_PROGRESS': (state, progress) => {
    state.progress = progress
  },
  'SET_BOOK_AVAILABLE': (state, bookAvailable) => {
    state.bookAvailable = bookAvailable
  }
}

const actions = {
  setFileName: ({ commit }, fileName) => {
    return commit('SET_FILENAME', fileName)
  },
  setMenuVisible: ({ commit }, menuVisible) => {
    return commit('SET_MENUVISIBLE', menuVisible)
  },
  setSettingVisible: ({ commit }, settingVisible) => {
    return commit('SET_SETTINGVISIBLE', settingVisible)
  },
  setDefaultFontSize: ({ commit }, defaultFontSize) => {
    return commit('SET_DEFAULT_FONT_SIZE', defaultFontSize)
  },
  setCurrentBook: ({ commit }, currentBook) => {
    return commit('SET_CURRENT_BOOK', currentBook)
  },
  setSettingFontPopup: ({ commit }, settingFontPopup) => {
    return commit('SET_SETTING_FONT_POPUP', settingFontPopup)
  },
  setDefaultFontFamily({ commit }, defaultFontFamily) {
    return commit('SET_DEFAULT_FONT_FAMILY', defaultFontFamily)
  },
  setDefaultTheme({ commit }, defaultTheme) {
    return commit('SET_DEFAULT_THEME', defaultTheme)
  },
  setProgress({ commit }, progress) {
    return commit('SET_PROGRESS', progress)
  },
  setBookAvailable({ commit }, bookAvailable) {
    return commit('SET_BOOK_AVAILABLE', bookAvailable)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
